package org.example;

/**
 通过instrumentation机制,调用premain方法
 通过添加vm参数来实现agent功能
 -javaagent:E:\Workspaces\intellijidea2023\agent\agent-instrumentaion\target\agent-instrumentaion-1.0-SNAPSHOT.jar=agent_scy1hotconf=/www/newer/hot-seconds-remote.xml,disablePlugin=Hibernate
 -javaagent:E:\Workspaces\intellijidea2023\agent\agent-instrumentation2\target\agent-instrumentation2-1.0-SNAPSHOT.jar=agent_scy2
 https://zhuanlan.zhihu.com/p/636603910?utm_id=0
 目标 : 使本类中的process方法增强,在其前后打印一句话.
 */
public class AgentInstrumentationTest {
    public static void main(String[] args) {

        System.out.println("AgentInstrumentationTest类的main方法执行了------Runtime.getRuntime" +Runtime.getRuntime());
        System.out.println("");
        while (true) {
            try {
                Thread.sleep(5000L);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

            process();
        }
    }

    /**
     *
     */
    public static void process() {
        System.out.println("AgentInstrumentationTest类中的process方法执行了-----Runtime.getRuntime="+Runtime.getRuntime());
    }
}
